import request from '@/utils/request'

// 查询请假记录列表
export function listVacation_record(query) {
    return request({
        url: '/ehr/vacation_record/list',
        method: 'get',
        params: query
    })
}

// 查询请假记录详细
export function getVacation_record(vacationRecordId) {
    return request({
        url: '/ehr/vacation_record/' + vacationRecordId,
        method: 'get'
    })
}

// 新增请假记录
export function addVacation_record(data) {
    return request({
        url: '/ehr/vacation_record',
        method: 'post',
        data: data
    })
}

// 修改请假记录
export function updateVacation_record(data) {
    return request({
        url: '/ehr/vacation_record',
        method: 'put',
        data: data
    })
}

// 提交审批
export function approvalVacation(data) {
    return request({
        url: '/ehr/vacation_record/approval',
        method: 'post',
        data: data
    })
}

// 删除请假记录
export function delVacation_record(vacationRecordId) {
    return request({
        url: '/ehr/vacation_record/' + vacationRecordId,
        method: 'delete'
    })
}

// 计算请假总工时
export function getWorkingHours(startDate, startTime, endDate, endTime) {
    return request({
        url: '/ehr/vacation_record/getWorkingHours',
        method: 'get',
        params: {
            'startDate': startDate,
            'startTime': startTime,
            'endDate': endDate,
            'endTime': endTime
        }
    })
}

// 获取剩余年假
export function getPaidVacation(partyId) {
    return request({
        url: '/ehr/vacation_record/getPaidVacation',
        method: 'get',
        params: {
            'partyId': partyId
        }
    })
}

// 校验请假重复
export function checkRepeated(partyId, startDate, startTime, endDate, endTime) {
    return request({
        url: '/ehr/vacation_record/checkRepeated',
        method: 'get',
        params: {
            'partyId': partyId,
            'startDate': startDate,
            'startTime': startTime,
            'endDate': endDate,
            'endTime': endTime
        }
    })
}

// 年假记账
export function recordAnnualVaction(partyId, periodAccount, vacationHours) {
    return request({
        url: '/ehr/vacation_record/recordAnnualVaction',
        method: 'get',
        params: {
            'partyId': partyId,
            'periodAccount': periodAccount,
            'vacationHours': vacationHours
        }
    })
}

// 年假记账恢复
export function recoverAnnualVaction(partyId, periodAccount, vacationHours) {
    return request({
        url: '/ehr/vacation_record/recoverAnnualVaction',
        method: 'get',
        params: {
            'partyId': partyId,
            'periodAccount': periodAccount,
            'vacationHours': vacationHours
        }
    })
}

// 获取业务字典选择框列表
export function getEntityDictsForSearch(entityField) {
    return request({
        url: "/ehr/enum/entity/search/" + entityField,
        method: "get",
    });
}
// 获取业务字典选择框列表
export function getPersonDict(query) {
    return request({
        url: '/ehr/enum/person/search/',
        method: 'get',
        params: query
    });
}